package cn.zwh;

import java.awt.event.ActionListener;
import java.awt.event.MouseListener;
import java.awt.event.ActionEvent;
import java.awt.Graphics;
import java.awt.Color;
public class frameListener implements GoBangconfig,MouseListener{
    public GoBangframe gf;
    public int turn=1;
    public void setGraphics(GoBangframe gf) {
        this.gf=gf;
    }
    public void mouseClicked(java.awt.event.MouseEvent e) {
        int x=e.getX();
        int y=e.getY();
        int countx=(x/40)*40+20;
        int county=(y/40)*40+20;
        Graphics g=gf.getGraphics();
        if(gf.isAvail[(countx-20)/40][(county-20)/40]!=0) {
            System.out.println("�˴��Ѿ��������ˣ������������ط�");
        }
        else {
            int colu=(countx-20)/40;
            int ro=(county-20)/40;
            if(turn==1) {
                g.setColor(Color.black);
                g.fillOval(countx-size/2, county-size/2, size, size);
                gf.isAvail[colu][ro]=1;
                turn++;
            }
            else {
                g.setColor(Color.white);
                g.fillOval(countx-size/2, county-size/2, size, size);
                gf.isAvail[colu][ro]=2;
                turn--;
            }
        }
    }
    public void mousePressed(java.awt.event.MouseEvent e) {
    }
    public void mouseReleased(java.awt.event.MouseEvent e) {
    }
    public void mouseEntered(java.awt.event.MouseEvent e) {
    }
    public void mouseExited(java.awt.event.MouseEvent e) {
    }
}
